package client.comm.baoding.ui

import android.content.Intent
import android.view.View
import client.comm.baoding.BaseMiddleActivity
import client.comm.baoding.R
import client.comm.baoding.databinding.ActivityPersoninfoBinding
import client.comm.baoding.ui.vm.PersonInfoViewModel

class PersonInfoActivity : BaseMiddleActivity<PersonInfoViewModel, ActivityPersoninfoBinding>() {

    override fun getLayout(): Int {
        return R.layout.activity_personinfo
    }

    override fun initView() {
        binding?.apply {
            event = this@PersonInfoActivity
            vm = viewModel
            emptyLayout.setOnClickListener { viewModel.userInfo() }
        }
    }

    fun editUserIk() {
    }

    override fun observerUI() {
        viewModel.callUser.observe(this, {
            it?.let {
                if (it.isSuccess) {
                    binding.userInfo = it.data

//                    if (it.data?.status != 2) {
//                        binding.real.visibility = View.VISIBLE
//                    }



                    var realName: String = ""
                    when (it.data?.status) {
                        0 -> realName = "未审核"
                        1 -> realName = "审核中"
                        2 -> realName = "已实名"
                    }
                    binding.realnameVerifyTxt = realName

                    binding.emptyLayout.visibility = View.GONE
                }
            }
        })

    }

    override fun initData() {
        viewModel.userInfo()
    }

    override fun initViewModel(): PersonInfoViewModel = createViewModel()

    //选择上传头像

    //修改交易密码
    fun xgjymm() {
        startActivity(Intent(this@PersonInfoActivity, XgzjmmActivity::class.java))
    }

    //修改密码
    fun xgmm() {
        startActivity(Intent(this@PersonInfoActivity, XgmmActivity::class.java))
    }

    fun setskxx() {
        startActivity(Intent(this@PersonInfoActivity, SetSkxxActivity::class.java))
    }

}